<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Dashboard Template for Bootstrap</title>
    <link th:href="@{/css/bootstrap.min.css}" rel="stylesheet">
    <link th:href="@{/css/dashboard.css}" rel="stylesheet">
    <style type="text/css">
        /* Chart.js */
        @-webkit-keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }
        @keyframes chartjs-render-animation {
            from {
                opacity: 0.99
            }
            to {
                opacity: 1
            }
        }
        .chartjs-render-monitor {
            -webkit-animation: chartjs-render-animation 0.001s;
            animation: chartjs-render-animation 0.001s;
        }
    </style>
</head>
<body>
<!--	顶部导航栏  list中的  顶部 和侧边栏都进行删除  然后去dashboard.html 中 定义 th:fragment="topbar" 用来做插入部分 注意模板引擎语法-->
<!-- <div th:insert="~{dashboard::topbar}"></div>   进行了  公共 页面抽取后就要重新命名插入  各种公共部分都可以抽取 -->
<div th:insert="~{commons/commons::topbar}"></div>   进行了  公共 页面抽取后就要重新命名插入 -->
<!--侧边栏-->
<div class="container-fluid">
    <div class="row">
        <!-- 第一 侧边栏 将原有的list中的侧边栏删除  二 dashboard.html 中 找侧边栏 定义 th:fragment="sidebar 三：进行下边的插入操作
        顶部导航栏也是一样的操作-->
        <!--	<div th:insert="~{dashboard::sidebar}" ></div>-->
        <div th:insert="~{commons/commons::sidebar}" ></div>
        <!--  这下面就只剩 内容了-->
        <!--将数据库数据 遍历得到-->
        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <form th:action="@{/emp}" method="post" >
                <!--添加一个隐藏域,如果没有id的话，id会自增-->
                <input type="hidden" name="id" th:value="${emp.getId()}">
                <div class="form-group" ><label>员工姓名</label>
                    <input th:value="${emp.getLastName()}" class="form-control"
                           placeholder="名字" type="text" name="lastName">
                </div>
                <div class="form-group" ><label>邮箱</label>
                    <input th:value="${emp.getEmail()}" class="form-control"
                           placeholder="邮箱" type="email" name="email">
                </div>
                <div class="form-group"><label>性别</label><br/>
                    <div class="form-check form-check-inline">
                        <input th:checked="${emp.getGender()==1}"
                               class="form-check-input"
                               name="gender" type="radio"
                               value="1">
                        <label class="form-check-label">男</label>
                    </div>
                    <div class="form-check form-check-inline">
                        <!--checked为布尔值-->
                        <input th:checked="${emp.getGender()==0}"
                               class="form-check-input"
                               name="gender" type="radio"
                               value="0">
                        <label class="form-check-label">女</label>
                    </div>
                </div>
                <div class="form-group" >
                    <label>所属部门</label>
                    <!--我们在controller接收的是一个Employee，所以我们需要提交的是其中一个属性！-->
                    <select class="form-control" name="department.id">
                        <!--selected为布尔值-->
                        <option th:selected="${dept.getId()==emp.getDepartment().getId()}"
                                th:each="dept:${departments}" th:text="${dept.getDepartmentName()}"
                                th:value="${dept.getId()}"></option>
                    </select>
                </div>
                <div class="form-group" >
                    <label >生日</label>
<!--                    ${#dates.format(emp.getBirth(),'yyyy-MM-dd')} 出错的地方-->
                    <input th:value="${#dates.format(emp.getBrith(),'yyyy-MM-dd')}"
                           class="form-control" placeholder="yyyy-MM-dd" type="text" name="brith">
                </div>
                <button class="btn btn-primary" type="submit">确认修改</button>
            </form>

        </main>
    </div>
</div>
<script type="text/javascript" src="asserts/js/jquery-3.2.1.slim.min.js"></script>
<script type="text/javascript" src="asserts/js/popper.min.js"></script>
<script type="text/javascript" src="asserts/js/bootstrap.min.js"></script>
<!-- Icons -->
<script type="text/javascript" src="asserts/js/feather.min.js"></script>
<script>
    feather.replace()
</script>
<!-- Graphs -->
<script type="text/javascript" src="asserts/js/Chart.min.js"></script>
<script>
    var ctx = document.getElementById("myChart");
    var myChart = new Chart(ctx, {
        type: 'line',
        data: {
            labels: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
            datasets: [{
                data: [15339, 21345, 18483, 24003, 23489, 24092, 12034],
                lineTension: 0,
                backgroundColor: 'transparent',
                borderColor: '#007bff',
                borderWidth: 4,
                pointBackgroundColor: '#007bff'
            }]
        },
        options: {
            scales: {
                yAxes: [{
                    ticks: {
                        beginAtZero: false
                    }
                }]
            },
            legend: {
                display: false,
            }
        }
    });
</script>
</body>
</html>